package com.baaio.util;

import java.io.File;

/**
 * 用来查找config.xml配置文件的绝对路径
 * 
 * 
 */
public class GetConfig
{

    private static String path2;
    private static String ff = "cfg";

    protected static String path()
    {

        String str;
        try
        {
            File f = new File(ff);
            str = GetConfig.getConfig(f);
            if (str == null || str == "null")
            {
                new AddConfigFrame();

            }
            return str;
        }
        catch (Exception e)
        {
            ff = GetRealPath.getRealpath();
            File f = new File(ff);
            str = GetConfig.getConfig(f);
            if (str == null || str == "null")
            {
                new AddConfigFrame();

            }
            return str;
        }

    }
    
    private static String getConfig(File f)
    {

        File[] list = f.listFiles();
        for (File fff : list)
        {
            if (fff.isDirectory())
            {

                getConfig(fff);
            }
            else if (fff.isFile())
            {
                if (fff.getName().trim().equals("config.xml"))
                {
                    path2 = fff.getPath();

                }
            }
            else
            {
                getConfig(fff);
            }
        }
        return path2;
    }
}
